package com.xmut.rc.controller;

import com.xmut.rc.common.Result;
import com.xmut.rc.service.RolePermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: 角色权限管理
 * @author: XS
 * @date: 2022/5/23
 */
@Api(tags = "角色权限管理")
@RestController
@RequestMapping("/system/role-permission")
@Slf4j
public class RolePermissionController {

    @Autowired
    private RolePermissionService rolePermissionService;

    /**
     * 获取全部角色
     *
     * @return
     */
    @ApiOperation(value = "更新用户角色", notes = "更新用户角色")
    @GetMapping("/updateRolePermission")
    public Result<?> updateRolePermission(@RequestParam(name = "roleId") String roleId,
                                          @RequestParam(name = "permissionIds") String permissionIds) {
        if (rolePermissionService.updateUserRole(roleId, permissionIds)) {
            return Result.OK("操作成功");
        } else {
            return Result.error("操作失败");
        }
    }
}

